/*
-----------------------------------------------------------------------------
This source file is part of Labor3D
(Labor 3D Graphics Engine)

Copyright (c) 2009-2020 Rock Mao
* creator : Rock Mao
* created : 2009-5-2   21:45
* filename: LaborCoreDef.h

-----------------------------------------------------------------------------
*/
#ifndef __LABORCORE_DEF_H__
#define __LABORCORE_DEF_H__

//*******************************************************************
// namespace define
//*******************************************************************

#define NAMESPACE_LABOR3D_BEGIN namespace Labor {
#define NAMESPACE_LABOR3D_END	 }


//*******************************************************************
// platform define
//*******************************************************************

#define LABOR_PLATFORM_WIN32 1
#define LABOR_PLATFORM_LINUX 2
#define LABOR_PLATFORM_APPLE 3

#define LABOR_ENDIAN_LITTLE 1
#define LABOR_ENDIAN_BIG 2

#define LABOR_ARCHITECTURE_32 1
#define LABOR_ARCHITECTURE_64 2


#   define LABOR_ARCH_TYPE LABOR_ARCHITECTURE_32

#if defined( _WIN32 ) || defined( WIN32 )

	#define LABOR_PLATFORM LABOR_PLATFORM_WIN32
#elif defined( __APPLE_CC__)
#   define LABOR_PLATFORM LABOR_PLATFORM_APPLE
#else
#   define LABOR_PLATFORM LABOR_PLATFORM_LINUX
#endif


//*******************************************************************
// export define
//*******************************************************************

#if LABOR_PLATFORM == LABOR_PLATFORM_WIN32

#	if defined(LABOR_STATIC_LIB)
#		define LABORCORE_API 
#		define LABORCORE_FUNC_API	extern "C" 
#		define LABORCORE_GLOBAL_API extern
#	else
#		if defined( LABORCORE_EXPORTS )
#			define LABORCORE_API		__declspec( dllexport )
#			define LABORCORE_FUNC_API	extern "C" __declspec( dllexport )
#			define LABORCORE_GLOBAL_API	extern __declspec( dllexport )
#		else
#			define LABORCORE_API		__declspec( dllimport )
#			define LABORCORE_FUNC_API	extern "C" __declspec( dllimport )
#			define LABORCORE_GLOBAL_API	extern __declspec( dllimport )
#       endif//// end if defined( LABORCORE_EXPORTS )
#   endif /// if defined(LABOR_STATIC_LIB)

#	define WIN32_LEAN_AND_MEAN
#	include <windows.h>
#	include <windowsx.h>
#	elif defined PLATFORM_LINUX
	// linux code
#endif /// #if LABOR_PLATFORM


#include <string>
#include <assert.h>
typedef std::wstring CLString;
//typedef std::string CLString;

/// Useful macros
#define SafeDelete(p)       { if(p) { delete (p);     (p)=NULL; } }
#define SafeDeleteArray(p) { if(p) { delete[] (p);   (p)=NULL; } }

template <typename T> int  SafeRelease(T& obj)
{
	if(obj)
	{
		int refCount = obj->Release();
		obj=NULL;
		return refCount;
	}
	return 0;
}

template<typename _ChildT , typename _ParentT> bool Labor_Convert(_ChildT* & _ch , _ParentT* parent)
{
	_ChildT* pChild = dynamic_cast<_ChildT*>(parent);
	if(pChild == NULL) return false;
	_ch = pChild ;
	return true;
}
#endif /// __LABORCORE_DEF_H__
